﻿@page "/"
@using MusicX.Web.Shared.Home

<ErrorsList Errors="response?.Errors" />

@if (this.response?.Data?.RandomSongs == null || this.response?.Data?.NewestSongs == null)
{
    <p><em>Loading...</em></p>
}
else
{
    <h2>Few random songs</h2>
    foreach (var song in this.response.Data.RandomSongs)
    {
        <SongCard Song="song"></SongCard>
    }

    <div class="clearfix"></div>

    <h2>Newest songs</h2>
    foreach (var song in this.response.Data.NewestSongs)
    {
        <SongCard Song="song"></SongCard>
    }

    <div class="clearfix"></div>
}

@code
{
    ApiResponse<IndexListsResponseModel> response;

    protected override async Task OnInitializedAsync()
    {
        this.response = await this.ApiClient.GetIndexLists();
    }
}
